// 属性读写
var obj = {x: 1, y : 2}
console.log(obj.x); //1
console.log(obj['y']); //2

obj['x'] = 3;
obj.y = 4;
console.log(obj.x); // 3
console.log(obj['y']); // 4

// 对象的遍历方法
var obj = {x1: 1,x2: 2}
var i = 1,n = 2;

for(;i <= n;i++){
    console.log(obj['x'+i]);
}
// 输出1，2

var p;
for(p in obj){
    console.log(obj[p]);
}

// 读写异常
var obj = {x:1};
obj.y; // undefined
var yx = obj.y.z // TypeError:Cannot read property 'z' of undefined
obj.y.z = 2; //// TypeError:Cannot read property 'z' of undefined

var yz;
if(obj.y){
    yz = obj.y.z 
}

// 也可以巧用and运算符
var yz = obj&&obj.y&&obj.y.z

// 属性删除

delete Object